// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: chensili

#pragma once

#include <memory>
#include <utility>

#include "coin2/exchange/base/symbology/product_info.h"

using coin2::exchange::base::symbology::IProductInfo;
using coin2::exchange::base::symbology::IProductHolder;

namespace appcoin2::support::symbology {
class PyProductInfo {
 public:
  explicit PyProductInfo(const IProductInfo& product_info) :
    product_info_(product_info) {}
  bool is_inverse() const { return product_info_.is_inverse(); }
  double contract_value() const { return product_info_.contract_value(); }
  double maker_fee_rate() const { return product_info_.maker_fee_rate(); }
  double taker_fee_rate() const { return product_info_.taker_fee_rate(); }
  double min_amount() const { return product_info_.min_amount(); }
  double min_qty() const { return product_info_.min_qty(); }
  double round_down(double price) const { return product_info_.tick_price().RoundDown(price); }
  double round_up(double price) const { return product_info_.tick_price().RoundUp(price); }
  double first_tick_size() const { return product_info_.first_tick_size(); }
  std::string asset() const { return product_info_.asset(); }
  double asset_multiplier() const { return product_info_.asset_multiplier(); }
  std::string DebugString() const { return product_info_.DebugString(); }

 private:
  const IProductInfo& product_info_;
};

class PyProductHolder {
 public:
  explicit PyProductHolder(std::unique_ptr<IProductHolder> product_holder) :
      product_holder_(std::move(product_holder)),
      product_info_(product_holder_->product_info()) {}
  const PyProductInfo& product_info() const { return product_info_; }
 private:
  std::unique_ptr<IProductHolder> product_holder_;
  const PyProductInfo product_info_;
};

}  // namespace appcoin2::support::symbology
